package com.xqboss.apps.controller.synthesis;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xqboss.apps.dto.synthesis.SynthesisUserRecordPageDto;
import com.xqboss.apps.service.synthesis.SynthesisUserRecordService;
import com.xqboss.apps.vo.synthesis.SynthesisUserRecordVo;
import com.xqboss.common.core.controller.BaseController;
import com.xqboss.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author Trent
 * @date 2023/8/15
 */
@Api(tags = "合成-用户合成记录")
@RestController
@RequestMapping("/apps/synthesis/record/")
public class AppSynthesisUserRecordController extends BaseController {

    @Autowired
    private SynthesisUserRecordService synthesisUserRecordService;

    @ApiOperation("获取用户合成记录")
    @GetMapping("list")
    public R<List<SynthesisUserRecordVo>> list(@Validated SynthesisUserRecordPageDto pageDto){
        return R.ok(synthesisUserRecordService.userSynthesisList(pageDto, getUserId()));
    }

    @ApiOperation("用户合成记录详情")
    @GetMapping("detail/{recordId}")
    public R<SynthesisUserRecordVo> detail(@Validated @PathVariable("recordId")
                                               @ApiParam(value = "详情ID", required = true)
                                               @NotNull(message = "详情ID不能为空")
                                               Long recordId) {
        return R.ok(synthesisUserRecordService.detail(recordId, getUserId()));
    }

}
